//
//  HomeFirstRowCell.m
//  StarPhone
//
//  Created by sxsk on 2025/2/17.
//

#import "HomeFirstRowCell.h"
#import "StarTimerManager.h"
@implementation HomeFirstRowCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    StarTimerManager *timerManager = [StarTimerManager sharedInstance];
    timerManager.timerCount = 10 * 60 * 60;
    if (timerManager.timer == nil) {
        timerManager.timer = [NSTimer scheduledTimerWithTimeInterval:1 repeats:true block:^(NSTimer * _Nonnull timer) {
            timerManager.timerCount = timerManager.timerCount - 1;
            self.timerLabel.text = [self getTimeString];
        }];
        
    }
    [[NSRunLoop currentRunLoop] addTimer:timerManager.timer forMode:NSRunLoopCommonModes];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (NSString *)getTimeString {
    
    NSInteger timeCount = [StarTimerManager sharedInstance].timerCount;
    NSInteger hours = timeCount / 3600;
    NSInteger min = (timeCount - hours * 60 * 60) / 60;
    NSInteger sec = timeCount % 60;
    NSString *timerString = [NSString stringWithFormat:@"当前通信时间倒计时：%02ld:%02ld:%02ld",hours,min,sec];
    return timerString;
}


@end
